package com.ncbee.base.config.common.converter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @Author fengzirong
 * @DESC
 * @Date 2018/12/3 14:04
 **/
public class DateConverter implements Converter<String, LocalDate> {
    private static final Logger logger = LoggerFactory.getLogger(DateConverter.class);

    @Override
    public LocalDate convert(String s){
        LocalDate localDate=null;
        if("".equals(s)||s==null){
            return localDate;
        }
        try{
            localDate=LocalDate.parse(s, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }catch (Exception  e){
            logger.error("localDate参数绑定错误!");
        }
        return localDate;
    }
}
